/*
 * SwingUtil.java
 */

package xq.swing;

import java.awt.Color;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map.Entry;
import javax.swing.JFrame;
import javax.swing.UIManager;
import xq.util.LoggerUtil;

/**
 *
 * @author ThorntonRP
 */
public class SwingUtil {

	public static void initSystemLookAndFeel() {
		try {
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		} catch (Exception ex) {
			LoggerUtil.getClassLogger().warn("Failed to set system look and feel.", ex);
		}
	}
	
	public static void dumpLookAndFeelDefaultColors() {
		List<String> values = new ArrayList<String>();
		for (Entry<Object, Object> entry : UIManager.getDefaults().entrySet()) {
			if (entry.getValue() instanceof Color) {
				values.add((String) entry.getKey() + "=" + entry.getValue());
			}
		}
		Collections.sort(values);
		for (String value : values) {
			System.out.println(value);
		}
	}
	
	public static void runFrame(final JFrame f) {
        java.awt.EventQueue.invokeLater(new Runnable() {
			@Override
            public void run() {
                f.setVisible(true);
            }
        });
	}
}
